package zmee.bid.formplugin;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.field.*;
import kd.bos.form.plugin.AbstractFormPlugin;

import java.util.EventObject;

public class SrcBiddocPlugin extends AbstractFormPlugin {
    @Override
    public void afterBindData(EventObject e) {
        this.getControl("");
    }

    @Override
    public void propertyChanged(PropertyChangedArgs e) {
        String name = e.getProperty().getName();
        Object changeSet = e.getChangeSet()[0].getNewValue();
        if("biztype".equals(name)){
            DynamicObject row=(DynamicObject)changeSet;
            String number=row.getString("number");
            TextEdit zmee_textfield1 = this.getControl("zmee_textfield1");//招标（采购）人
            BasedataEdit base=this.getControl("zmee_basedatafield");//项目所在地
            DateEdit date=this.getControl("zmee_datefield1");//计划实施采购时间
            ComboEdit combo=this.getControl("zmee_combofield2");//采购类型
            ComboEdit combofield3 = this.getControl("zmee_combofield3");//二级类型
            TextEdit textareafield5 = this.getControl("zmee_textareafield5");//采购方式选用说明
            ComboEdit combofield5 = this.getControl("zmee_combofield5");//是否在年度预算范围内
            TextEdit textfield2 = this.getControl("zmee_textfield2");//合同估算价
            TextEdit control = this.getControl("zmee_textareafield");//立项及预算情况说明
            TextEdit control1 = this.getControl("zmee_textareafield1");//项目概况
            TextEdit control2 = this.getControl("zmee_textareafield2");//招标（采购）范围
            MulComboEdit control3 = this.getControl("zmee_mulcombofield");//采购公告发布网站
            ComboEdit control4 = this.getControl("zmee_combofield");//是否设置最高限价
            RadioEdit radiofield = this.getControl("zmee_radiofield");//招标代理公司
            TextEdit control5 = this.getControl("zmee_textfield");//招标代理公司名称
            ComboEdit control6 = this.getControl("zmee_combofield4");//报价方式
            TextEdit control7 = this.getControl("zmee_textareafield8");//标段划分
            TextEdit control8 = this.getControl("zmee_textareafield4");//供应商资格要求
            TextEdit control9 = this.getControl("zmee_textareafield3");//专家产生程序
            ComboEdit control10 = this.getControl("zmee_combofield1");//评审办法
            TextEdit control11 = this.getControl("zmee_textareafield7");//标前准备情况
            DateEdit control12 = this.getControl("zmee_datefield");//计划实施日期
            if("1104".equals(number)){
                zmee_textfield1.setMustInput(true);
                base.setMustInput(true);
                date.setMustInput(true);
                combo.setMustInput(true);
                combofield3.setMustInput(true);
                textareafield5.setMustInput(true);
                combofield5.setMustInput(true);
                textfield2.setMustInput(true);
                control.setMustInput(true);
                control1.setMustInput(true);
                control2.setMustInput(true);
                control3.setMustInput(true);
                control4.setMustInput(true);
                radiofield.setMustInput(true);
                control5.setMustInput(true);
                control6.setMustInput(true);
                control7.setMustInput(true);
                control8.setMustInput(true);
                control9.setMustInput(true);
                control10.setMustInput(true);
                control11.setMustInput(true);
                control12.setMustInput(true);
            }else{
                zmee_textfield1.setMustInput(false);
                base.setMustInput(false);
                date.setMustInput(false);
                combo.setMustInput(false);
                combofield3.setMustInput(false);
                textareafield5.setMustInput(false);
                combofield5.setMustInput(false);
                textfield2.setMustInput(false);
                control.setMustInput(false);
                control1.setMustInput(false);
                control2.setMustInput(false);
                control3.setMustInput(false);
                control4.setMustInput(false);
                radiofield.setMustInput(false);
                control5.setMustInput(false);
                control6.setMustInput(false);
                control7.setMustInput(false);
                control8.setMustInput(false);
                control9.setMustInput(false);
                control10.setMustInput(false);
                control11.setMustInput(false);
                control12.setMustInput(false);
            }

        }

        if("zmee_combofield1".equals(name)){
            String s = changeSet.toString();
            DecimalEdit control10 = this.getControl("zmee_decimalfield");//评审办法
            DecimalEdit control11 = this.getControl("zmee_decimalfield1");//标前准备情况
            DecimalEdit control12 = this.getControl("zmee_decimalfield2");//计划实施日期
            switch (s){
                case "9":
                    control10.setMustInput(true);
                    control11.setMustInput(true);
                    control12.setMustInput(true);
                default:
                    control10.setMustInput(false);
                    control11.setMustInput(false);
                    control12.setMustInput(false);
            }
        }
    }
}
